# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=ncdu2
pkgver=2.6
pkgrel=0
pkgdesc="Disk usage analyzer with an ncurses interface"
url="https://dev.yorhel.nl/ncdu"
license="MIT"
arch="x86_64 aarch64" # Limited by zig aport
makedepends="chrpath zig ncurses-dev zstd-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://dev.yorhel.nl/download/ncdu-$pkgver.tar.gz"
builddir="$srcdir/ncdu-$pkgver"
replaces=ncdu

# We may want other than "baseline" for other targets, when enabled by zig
case "$CARCH" in
	aarch64|x86_64) _cputarget=baseline ;;
esac

build() {
	zig build -Doptimize=ReleaseSafe -Dpie=true ${_cputarget:+-Dcpu="$_cputarget"}
}

check() {
	zig build test
}

package() {
	install -Dm755 zig-out/bin/ncdu "$pkgdir"/usr/bin/ncdu
	chrpath -d "$pkgdir"/usr/bin/ncdu

	make install-doc PREFIX="$pkgdir/usr"

	install -Dm644 LICENSES/MIT.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

sha512sums="
e94612a56db3831d993d6ffd8c69a4cc2418ebf4b9a810e28444c103225ccc1f53ae31e448b94d40ccf2ab7d3a0af6e8ee02bc700123aca872b3bb35108e3d14  ncdu2-2.6.tar.gz
"
